package cn.lg.soar.system.auth.model;

import cn.lg.soar.common.util.BeanCopier;
import cn.lg.soar.system.auth.entity.Menu;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
public class MenuVo extends Menu {

    private static final long serialVersionUID = 3410574829954698131L;

    public final static BeanCopier<MenuVo, Menu> TO_ENTITY = BeanCopier.create(MenuVo.class, Menu.class);
    public final static BeanCopier<Menu, MenuVo> FROM_ENTITY = BeanCopier.create(Menu.class, MenuVo.class);

    private List<Long> permitIds;

    private List<MenuVo> permits;

    public MenuVo() {
    }

    public MenuVo(Menu data) {
        FROM_ENTITY.copy(data, this);
        this.setId(data.getId());
        this.setParentId(data.getParentId());
    }

    public Menu toMenu(){
        Menu convert = TO_ENTITY.convert(this);
        convert.setId(this.getId());
        convert.setParentId(this.getParentId());
        return convert;
    }
}
